<template>
	<view class="page-content">
		<u-loading-page :loading="loading" bg-color="#e8e8e8"></u-loading-page>
		<u--form labelWidth='auto' labelAlign="left" labelPosition="left" :model="detailform" :rules="rules"
			ref="form1">
			<u-form-item label="申请时间" prop="applyTime" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.applyTime"></u--input>
			</u-form-item>
			<u-form-item label="服务项目" prop="items" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.items"></u--input>
			</u-form-item>
			<u-form-item label="申请人姓名" prop="applyName" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.applyName"></u--input>
			</u-form-item>
			<u-form-item label="申请人身份证号" prop="applyIdno" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.applyIdno"></u--input>
			</u-form-item>
			<u-form-item label="联系电话" prop="applyPhone" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.applyPhone"></u--input>
			</u-form-item>
			<u-form-item label="性别" prop="applySex" borderBottom @click="showSex = true" ref="item1">
				<u--input v-model="detailform.applySex" inputAlign='center' disabled disabledColor="#ffffff"
					placeholder="请选择性别" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="人员类别" prop="applyType" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.applyType"></u--input>
			</u-form-item>
			<u-form-item label="是否居家养老服务补贴对象" prop="issubsidy" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.issubsidy"></u--input>
			</u-form-item>
			<u-form-item label="生活自理能力" prop="selfCareAbility" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.selfCareAbility"></u--input>
			</u-form-item>
			<u-form-item label="疾病类别" prop="diseaseCategory" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.diseaseCategory"></u--input>
			</u-form-item>
			<u-form-item label="照顾等级" prop="careLevel" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.careLevel"></u--input>
			</u-form-item>
			<u-line color="#2979ff"></u-line>
			<u-form-item label="是否残疾" prop="disable" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.disable"></u--input>
			</u-form-item>
			<u-form-item label="残疾类别" prop="disableCategory" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.disableCategory"></u--input>
			</u-form-item>
			<u-form-item label="残疾等级" prop="disableLevel" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.disableLevel"></u--input>
			</u-form-item>
			<u-form-item label="户籍省名称" prop="householdProvince" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.householdProvince"></u--input>
			</u-form-item>
			<u-form-item label="户籍市名称" prop="householdCity" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.householdCity"></u--input>
			</u-form-item>
			<u-form-item label="户籍区县名称" prop="householdDistrict" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.householdDistrict"></u--input>
			</u-form-item>
			<u-form-item label="户籍乡镇名称" prop="householdTown" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.householdTown"></u--input>
			</u-form-item>
			<u-form-item label="户籍村名称" prop="householdVillage" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.householdVillage"></u--input>
			</u-form-item>
			<u-form-item label="户籍街镇名称" prop="householdStreet" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.householdStreet"></u--input>
			</u-form-item>
			<u-form-item label="户籍地址" prop="householdRegisterAdd" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.householdRegisterAdd"></u--input>
			</u-form-item>
			<u-line color="#2979ff"></u-line>
			<u-form-item label="居住省名称" prop="permanentProvince" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.permanentProvince"></u--input>
			</u-form-item>
			<u-form-item label="居住州市名称" prop="permanentCity" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.permanentCity"></u--input>
			</u-form-item>

			<u-form-item label="居住区县名称" prop="permanentDistrict" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.permanentDistrict"></u--input>
			</u-form-item>
			<!-- <u-form-item label="居住乡镇名称" prop="permanentTown" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.permanentTown"></u--input>
			</u-form-item> -->
			<u-form-item label="居住街镇名称" prop="permanentStreet" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.permanentStreet"></u--input>
			</u-form-item>

			<u-form-item label="居住村名称" prop="permanentVillage" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.permanentVillage"></u--input>
			</u-form-item>

			<u-form-item label="居住地址" prop="permanentResidenceAdd" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.permanentResidenceAdd"></u--input>
			</u-form-item>
			<u-form-item label="居住状况" prop="livingStatus" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.livingStatus"></u--input>
			</u-form-item>
			<u-form-item label="房产所有人" prop="houseOwner" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.houseOwner"></u--input>
			</u-form-item>
			<u-form-item label="与所有人关系" prop="ownerRelationship" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.ownerRelationship"></u--input>
			</u-form-item>
			<u-form-item label="建筑面积" prop="floorArea" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.floorArea"></u--input>
			</u-form-item>
			<u-form-item label="住宅类型" prop="houseType" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.houseType"></u--input>
			</u-form-item>
			<u-form-item label="居住人数" prop="residents" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.residents"></u--input>
			</u-form-item>
			<u-form-item label="建成时间" prop="houseCreatedate" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.houseCreatedate"></u--input>
			</u-form-item>
			<u-form-item label="室数量" prop="roomcount" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.houseType"></u--input>
			</u-form-item>
			<u-form-item label="厅数量" prop="hallcount" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.residents"></u--input>
			</u-form-item>
			<u-form-item label="卫数量" prop="toiletcount" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.toiletcount"></u--input>
			</u-form-item>
			<u-line color="#2979ff"></u-line>
			<u-form-item label="紧急联系人姓名" prop="emergencyContactName" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.emergencyContactName">
				</u--input>
			</u-form-item>
			<u-form-item label="紧急联系人性别" prop="emergencyContactSex" borderBottom @click="showEmergencyContactSex = true"
				ref="item1">
				<u--input v-model="detailform.emergencyContactSex" inputAlign='center' disabled disabledColor="#ffffff"
					placeholder="请选择性别" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="紧急联系人电话" prop="emergencyContactPhone" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.emergencyContactPhone">
				</u--input>
			</u-form-item>

			<u-line color="#2979ff"></u-line>

			<u-form-item label="填写人员" prop="filloutName" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.filloutName">
				</u--input>
			</u-form-item>
			<u-form-item label="填写人身份证号" prop="filloutIdno" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.filloutIdno">
				</u--input>
			</u-form-item>
			<u-form-item label="填写人与申请人关系" prop="filloutRelationship" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.filloutRelationship">
				</u--input>
			</u-form-item>
			<u-form-item label="填写人电话" prop="filloutPhone" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.relationshipLevel">
				</u--input>
			</u-form-item>
			<u-form-item label="备注" prop="remark" borderBottom ref="item1">
				<u--input customStyle="font-weight: bold;margin: 5px;" inputAlign='center' shape='square' border="none"
					v-model="detailform.remark">
				</u--input>
			</u-form-item>
		</u--form>
		<u-row customStyle="margin:10px">
			<u-col span="12">
				<u-button class="custom-style" type="primary" size="small" @click="handel_submit_click" text="提交">
				</u-button>
			</u-col>
		</u-row>
		<u-action-sheet :show="showSex" :actions="actions" title="请选择性别" @close="showSex = false" @select="sexSelect">
		</u-action-sheet>
		<u-action-sheet :show="showEmergencyContactSex" :actions="actions" title="请选择性别"
			@close="showEmergencyContactSex = false" @select="emergencyContactSexSelect">
		</u-action-sheet>

	</view>
</template>

<script>
	import {
		transformPostBody,
		transformRequestURL
	} from "@/utils/requestParams.js";
	import {
		QueryGzAuditList,
		addGzAudit,
		updateGzAudit,
		getGzAudit,
		delGzAudit,
		QueryGzAuditHistory
	} from "@/api/elder/GzAudit.js";

	export default {
		data() {
			return {
				detailform: { //需要验证的属性必须设置，不能为空
					applyName: '', //申请人姓名
					applySex: '', //性别
					applyIdno: '', //身份证号码
				},
				loading: false, //加载中
				id: null,
				showSex: false,
				showEmergencyContactSex: false,
				actions: [{
						name: '男',
					},
					{
						name: '女',
					},
				],
				rules: {
					name: {
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					},
					idNumber: {
						type: 'string',
						required: true,
						message: '请填写身份证号',
						trigger: ['blur', 'change']
					},
					applySex: {
						type: 'string',
						max: 1,
						required: true,
						message: '请选择男或女',
						trigger: ['blur', 'change']
					},
					emergencyContactSex: {
						type: 'string',
						max: 1,
						required: true,
						message: '请选择男或女',
						trigger: ['blur', 'change']
					},
				},
			}
		},
		onLoad: function() {},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			this.$refs.form1.setRules(this.rules)
		},
		computed: {},
		methods: {
			sexSelect(item) {
				this.detailform.applySex = item.name
			},
			emergencyContactSexSelect(item) {
				this.detailform.emergencyContactSex = item.name
			},
			handel_submit_click() {
				this.$refs.form1.validate().then(res => {
					uni.$u.toast('校验通过,正在提交...')
					//提交修改
					this.loading = true;
					addGzAudit(this.detailform).then((response) => {
						console.log("addGzAudit", response);
						this.loading = false;
						this.$tab.navigateBack();
					});
				}).catch(errors => {
					uni.$u.toast('校验失败,请修改后再尝试提交')
				})
			}
		},

	}
</script>

<style lang="scss">
	page {
		background-color: white;
		display: flex;
		justify-content: center;
	}

	.page-content {
		width: 93%;
	}

	.custom-style {
		width: 80%;
		font-size: 20px;
		font-weight: bolder;
	}
</style>